import { prop, modelOptions, arrayProp, Ref } from '@typegoose/typegoose'
import { ApiProperty} from '@nestjs/swagger'
import { Episode } from './episode.model'

@modelOptions({
    schemaOptions:{
        timestamps:true,
        toJSON:{virtuals: true}
    }
})
export class Course {
    @ApiProperty({ description: '课程名称'})
    @prop()
    name: string


    @ApiProperty({ description: '封面图'})
    @prop()
    cover: string

    @arrayProp({ //相当于我在Episode里面查Course里面_id和Episode里面的course相等的带出来，需要populate
        ref:'Episode',
        localField:'_id',
        foreignField:'course'
    })
    episodes: Ref<Episode>[]

}